package com.javadroid.sgbd;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.javadroid.model.EmissoraModel;

public class EmissoraDao extends GenericDao{

	
	public List<EmissoraModel> getLista(){
		List<EmissoraModel> lista = new ArrayList<EmissoraModel>();
		String sql = "SELECT * FROM emissoras";
		try {
			PreparedStatement pstmt = getConnection().prepareStatement(sql);
			ResultSet rs = pstmt.executeQuery();
			
			while (rs.next()) {
				EmissoraModel model = new EmissoraModel();
				model.setId(rs.getInt("id"));
				model.setAtivo(rs.getBoolean("ativo"));
				model.setEmissora(rs.getString("emissora"));
				lista.add(model);
			}
			rs.close();
			pstmt.close();
			return lista;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}

}
